home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / Level 0 Macintosh 29Sep94 / Screen.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  12.5 KB  |  288 lines  |  [TEXT/KAHL]

  1. /* Screen.h */
  2.  
  3. #ifndef Included_Screen_h
  4. #define Included_Screen_h
  5.  
  6. /* Screen module depends on: */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* Memory */
  12. /* Menus */
  13. /* EventLoop */
  14. /* Scrap */
  15. /* Array */
  16. /* Files */
  17.  
  18. /* pixel location specifier type */
  19. /* coordinate system:  The global screen coordinates are left-right and top-bottom */
  20. /* with the origin in the upper-left corner of the primary screen. */
  21. typedef short OrdType;
  22.  
  23. /* limits of the OrdType value */
  24. #define ORDTYPEMIN (-32767)
  25. #define ORDTYPEMAX (32767)
  26.  
  27. /* window reference type */
  28. struct WinType;
  29. typedef struct WinType WinType;
  30.  
  31. /* specifies what the window should look like; eDialogWindow has no title */
  32. typedef enum {eDocumentWindow EXECUTE(=-9999),eDialogWindow,eModelessDialogWindow}WinForm;
  33.  
  34. /* specifies the supported patterns to use when drawing things */
  35. typedef enum {eWhite EXECUTE(=-91), eLightGrey, eMediumGrey, eDarkGrey, eBlack} Patterns;
  36.  
  37. /* whether there will be a close box on the window */
  38. typedef enum {eWindowNotClosable EXECUTE(= -8888), eWindowClosable} WinCloseType;
  39.  
  40. /* whether there will be a zoom box or maximize button on the window */
  41. typedef enum {eWindowNotZoomable EXECUTE(= -7777), eWindowZoomable} WinZoomType;
  42.  
  43. /* whether to let the system resize a window or not */
  44. typedef enum {eWindowNotResizable EXECUTE(= -6666), eWindowResizable} WinSizingType;
  45.  
  46. /* font characteristics; powers of 2 (for bit twiddling) */
  47. typedef enum {ePlain = 0, eBold = 1, eItalic = 2, eUnderline = 4} FontStyleType;
  48.  
  49. /* font types */
  50. typedef int FontType;
  51. typedef int FontSizeType;
  52.  
  53. /* bitmap type */
  54. struct Bitmap;
  55. typedef struct Bitmap Bitmap;
  56.  
  57. /* Initialize the screen management subsystem.  This routine must be called before */
  58. /* any graphics routines are called.  this routine initializes the entire Level 0 */
  59. /* module set except for some optional modules (like Network).  if it returns  */
  60. /* False then initialization failed and the program must terminate immediately. */
  61. MyBoolean                        InitializeScreen(void);
  62.  
  63. /* close all open windows and perform any cleanup or server disconnection before */
  64. /* the program terminates */
  65. void                                ShutdownScreen(void);
  66.  
  67. /* get size of screen.  If there are multiple screens, the result is implementation */
  68. /* defined, but should not be counted on.  On the Macintosh, this returns only the */
  69. /* size of the main screen.  Caveats aside, you are guarranteed that there is at */
  70. /* least this much screen space in the form of a complete rectangle. */
  71. OrdType                            GetScreenHeight(void);
  72. OrdType                            GetScreenWidth(void);
  73.  
  74. /* how big is a window's title bar */
  75. OrdType                            WindowTitleBarHeight(WinForm WindowKind);
  76.  
  77. /* how big are the other edges of a window */
  78. OrdType                            WindowOtherEdgeWidths(WinForm WindowKind);
  79.  
  80. /* create a new window.  if WindowKind = eDocumentWindow, then the window is a */
  81. /* standard window with a name (image is implementation defined).  In this case */
  82. /* Zoomable determines whether there will be a "Maximize" button, and Closable */
  83. /* determines whether there will be a "Close" button. */
  84. /* The window returned will be considered in the "disabled" state and any */
  85. /* objects installed in it should be disabled.  Eventually GetAnEvent will return */
  86. /* an active window change event disabling the window previously on top and */
  87. /* enabling this window.  if there are dialog boxes, then the window will be */
  88. /* created under the lowest dialog box */
  89. WinType*                        MakeNewWindow(WinForm WindowKind, WinCloseType Closable,
  90.                                             WinZoomType Zoomable, WinSizingType Resizing, OrdType Left,
  91.                                             OrdType Top, OrdType Width, OrdType Height,
  92.                                             void (*UpdateRoutine)(void* Refcon), void* Refcon);
  93.  
  94. /* change the size of the window.  The window will be guarranteed to be the specified */
  95. /* size, but significant portions may not be on screen, so be careful */
  96. void                                ResizeWindow(WinType* Window, OrdType Width, OrdType Height);
  97.  
  98. /* close a window and release all associated space.  The window refnum may be reused */
  99. /* An active window change event will be issued activating the window that is */
  100. /* next in the stack.  If there are dialog boxes open, then the most recently */
  101. /* created one must be disposed or it is an error. */
  102. void                                KillWindow(WinType* Window);
  103.  
  104. /* get the size of the usable portion of the window */
  105. OrdType                            GetWindowHeight(WinType* Window);
  106. OrdType                            GetWindowWidth(WinType* Window);
  107.  
  108. /* Get the global coordinate location of the window */
  109. OrdType                            GetWindowXStart(WinType* Window);
  110. OrdType                            GetWindowYStart(WinType* Window);
  111.  
  112. /* Adjust the global position of the window. */
  113. void                                SetWindowPosition(WinType* Window, OrdType NewXLocation,
  114.                                             OrdType NewYLocation);
  115.  
  116. /* Get what type of window it is */
  117. WinForm                            GetWindowKind(WinType* Window);
  118.  
  119. /* allow system to resize window after user clicked in some area */
  120. void                                UserGrowWindow(WinType* Window, OrdType X, OrdType Y);
  121.  
  122. /* bring window to the top of the window stack.  this will be silently ignored */
  123. /* if there are dialog boxes open. */
  124. void                                ActivateThisWindow(WinType* Window);
  125.  
  126. /* this routine helps make sure the rectangle fits on the screen.  If the rectangle */
  127. /* already fits on the screen, X and Y will not be adjusted, but if it doesn't, some */
  128. /* undefined adjustment will be made to ensure that the rectangle fits on the screen. */
  129. /* If the rectangle is so large that it can't be made to fit on the screen, then */
  130. /* the size of the window is reduced so that the window will fit on screen. */
  131. void                                MakeWindowFitOnScreen(OrdType* X, OrdType* Y,
  132.                                             OrdType* Width, OrdType* Height);
  133.  
  134. /* obtain the edge of a window, conforming to the user interface */
  135. /* guidelines of the implementation's platform */
  136. OrdType                            AlertLeftEdge(OrdType AlertWidth);
  137. OrdType                            AlertTopEdge(OrdType AlertHeight);
  138. OrdType                            DialogLeftEdge(OrdType DialogWidth);
  139. OrdType                            DialogTopEdge(OrdType DialogHeight);
  140.  
  141. /* change window's name.  name should be a null-terminated string.  the only windows */
  142. /* guarranteed to have a title bar are eDocumentWindow's. */
  143. void                                SetWindowName(WinType* Window, char* Name);
  144.  
  145. /* invoke a window's update routine.  normal updates redraw only the part of the */
  146. /* window that needs to be updated.  deferred updates always redraw the entire */
  147. /* window.  they are intended to be used for redrawing a window when it isn't safe */
  148. /* to actually perform the drawing, but they can be used to force a full redraw as */
  149. /* soon as possible. */
  150. void                                CallWindowUpdate(WinType* Window);
  151. void                                MarkForDeferredUpdate(WinType* Window);
  152. void                                PerformDeferredUpdates(void);
  153.  
  154. /* get the refcon from the window */
  155. void*                                GetWindowRefcon(WinType* Window);
  156.  
  157. /* set the clipping rectangle for the window.  Drawing outside of this rectangle */
  158. /* will not be change any of the window */
  159. void                                SetClipRect(WinType* Window, OrdType Left, OrdType Top,
  160.                                             OrdType Width, OrdType Height);
  161.  
  162. /* constrain the clipping rectangle for the window.  The new clipping rectangle is */
  163. /* the intersection of the specified one and the previous one. */
  164. void                                AddClipRect(WinType* Window, OrdType Left, OrdType Top,
  165.                                             OrdType Width, OrdType Height);
  166.  
  167. /* returns True if any part of the specified rectangle in the window is visible. */
  168. /* this is used for making redrawing more efficient. */
  169. MyBoolean                        IsRectVisible(WinType* Window, OrdType Left, OrdType Top,
  170.                                             OrdType Width, OrdType Height);
  171.  
  172. /* Draw a line one pixel thick.  XDisp and YDisp may be negative. */
  173. void                                DrawLine(WinType* Window, Patterns Pattern,
  174.                                             OrdType X, OrdType Y, OrdType XDisp, OrdType YDisp);
  175.  
  176. /* Draw a box with a 1 pixel thick frame.  Note that the last pixel touched */
  177. /* is X + XDisp - 1 and Y + YDisp - 1. */
  178. void                                DrawBoxFrame(WinType* Window, Patterns Pattern,
  179.                                             OrdType X, OrdType Y, OrdType XDisp, OrdType YDisp);
  180.  
  181. /* paint the box with the specified pattern */
  182. void                                DrawBoxPaint(WinType* Window, Patterns Pattern,
  183.                                             OrdType X, OrdType Y, OrdType XDisp, OrdType YDisp);
  184.  
  185. /* paint the box with white */
  186. void                                DrawBoxErase(WinType* Window, OrdType X, OrdType Y,
  187.                                             OrdType XDisp, OrdType YDisp);
  188.  
  189. /* And-mask the contents of the box with the pattern */
  190. void                                DrawBoxScreen(WinType* Window, Patterns Pattern,
  191.                                             OrdType X, OrdType Y, OrdType XDisp, OrdType YDisp);
  192.  
  193. /* Draw a box, but round off the corners with circles. */
  194. void                                DrawRoundBoxFrame(WinType* Window, Patterns Pattern,
  195.                                             OrdType X, OrdType Y, OrdType XDisp, OrdType YDisp,
  196.                                             OrdType DiameterX, OrdType DiameterY);
  197. void                                DrawRoundBoxPaint(WinType* Window, Patterns Pattern,
  198.                                             OrdType X, OrdType Y, OrdType XDisp, OrdType YDisp,
  199.                                             OrdType DiameterX, OrdType DiameterY);
  200. void                                DrawRoundBoxErase(WinType* Window, OrdType X, OrdType Y,
  201.                                             OrdType XDisp, OrdType YDisp, OrdType DiameterX, OrdType DiameterY);
  202.  
  203. /* circles */
  204. void                                DrawCircleFrame(WinType* Window, Patterns Pattern,
  205.                                             OrdType X, OrdType Y, OrdType XDisp, OrdType YDisp);
  206. void                                DrawCirclePaint(WinType* Window, Patterns Pattern,
  207.                                             OrdType X, OrdType Y, OrdType XDisp, OrdType YDisp);
  208. void                                DrawCircleErase(WinType* Window, OrdType X, OrdType Y,
  209.                                             OrdType XDisp, OrdType YDisp);
  210.  
  211. /* fill a triangle */
  212. void                                DrawTrianglePaint(WinType* Window, Patterns Pattern, OrdType X1,
  213.                                             OrdType Y1, OrdType X2, OrdType Y2, OrdType X3, OrdType Y3);
  214.  
  215. /* Get the ID of a heavier screen font (Macintosh == Chicago) */
  216. FontType                        GetUglyFont(void);
  217.  
  218. /* Get the ID of the default screen font (Macintosh == Geneva) */
  219. FontType                        GetScreenFont(void);
  220.  
  221. /* Get the ID of the normal monospaced font, usually courier or monaco */
  222. FontType                        GetMonospacedFont(void);
  223.  
  224. /* Get the ID of the named font.  If no such font exists, then it is an error */
  225. FontType                        GetFontByName(char* Name);
  226.  
  227. /* Get the total number of pixels high a line is using the specified font */
  228. OrdType                            GetFontHeight(FontType FontID, FontSizeType PointSize);
  229.  
  230. /* return a heap pointer containing the name of the font, null terminated */
  231. /* the heap pointer can be released with ReleasePtr. */
  232. char*                                GetNameOfFont(FontType FontID);
  233.  
  234. /* get number of fonts */
  235. long                                GetNumAvailableFonts(void);
  236.  
  237. /* get the FontType of an indexed font. indices are from 0 to GetNumAvailableFonts - 1 */
  238. FontType                        GetIndexedFont(long FontIndex);
  239.  
  240. /* find the total number of pixels long the string of text is */
  241. OrdType                            LengthOfText(FontType Font, FontSizeType PointSize, char* Text,
  242.                                             long Length, FontStyleType FontStyle);
  243.  
  244. /* draw a line of text */
  245. void                                DrawTextLine(WinType* Window, FontType Font, FontSizeType PointSize,
  246.                                             char* Text, long Length, OrdType X, OrdType Y,
  247.                                             FontStyleType FontStyle);
  248.  
  249. /* draw a line of text, but with white background and black letters */
  250. void                                InvertedTextLine(WinType* Window, FontType Font,
  251.                                             FontSizeType PointSize, char* Text, long Length,
  252.                                             OrdType X, OrdType Y, FontStyleType FontStyle);
  253.  
  254. /* move the specified rectangle of of pixels. XDisplacement and YDisplacement */
  255. /* positive mean to the right and down.  Area opened up is erased with white. */
  256. /* no area outside of the rectangle is touched. */
  257. void                                ScrollArea(WinType* Window, OrdType Left, OrdType Top, OrdType Width,
  258.                                             OrdType Height, OrdType XDisplacement, OrdType YDisplacement);
  259.  
  260. /* convert a raw packed-byte list of data (upper bit of each byte is leftmost */
  261. /* on the screen) to an internal bitmap */
  262. Bitmap*                            MakeBitmap(unsigned char* RawData, OrdType Width, OrdType Height,
  263.                                             long BytesPerRow);
  264.  
  265. /* dispose of the bitmap made by MakeBitmap */
  266. void                                DisposeBitmap(Bitmap* TheBitmap);
  267.  
  268. /* copy the bitmap to the area specified. */
  269. void                                DrawBitmap(WinType* Window, OrdType X, OrdType Y, Bitmap* TheBitmap);
  270.  
  271. /* logical-or the bitmap onto the window */
  272. void                                OrBitmap(WinType* Window, OrdType X, OrdType Y, Bitmap* TheBitmap);
  273.  
  274. /* Bit-clear the bitmap onto the window:  Where the bitmap is set, the */
  275. /* window will be erased; otherwise the window will be untouched */
  276. void                                BicBitmap(WinType* Window, OrdType X, OrdType Y, Bitmap* TheBitmap);
  277.  
  278. /* duplicate the bitmap */
  279. Bitmap*                            DuplicateBitmap(Bitmap* Original);
  280.  
  281. /* logical-or the first bitmap onto the second.  sizes must be the same */
  282. void                                BitmapOrIntoBitmap(Bitmap* NotChanged, Bitmap* IsChanged);
  283.  
  284. /* logical-and the first bitmap onto the second.  sizes must be the same */
  285. void                                BitmapAndIntoBitmap(Bitmap* NotChanged, Bitmap* IsChanged);
  286.  
  287. #endif
  288.